package com.shujia.wyh.day26.homework;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

/*
    ByteArrayOutputStream
 */
public class Test3 {
    public static void main(String[] args) throws IOException {
        //定义一个字节数组
        byte[] bytes = {97,98,99,100};

        //使用ByteArrayOutputStream往文件写入一个字节数组
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

        byteArrayOutputStream.write(bytes);
        System.out.println(byteArrayOutputStream);

        byteArrayOutputStream.write(bytes);
        System.out.println(byteArrayOutputStream);


        System.out.println("============================================");
        byte[] bytes2 = {100,101,102,103};
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes2);

        int read = byteArrayInputStream.read();
        System.out.println(read);
    }

}
